using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: daiduong19051986@gmail.com 
	/// <summary>
	
    public class DocLinkInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			DB,
			TRANS_TYPE,
			REFERENCE,
			URL,
			TITLE,
			CATEGORY,
			SUBJECT,
			AUTHOR,
			KEYWORDS,
			COMMENTS
		}
		private Int32 _ID;
		private String _DB;
		private String _TRANS_TYPE;
		private String _REFERENCE;
		private String _URL;
		private String _TITLE;
		private String _CATEGORY;
		private String _SUBJECT;
		private String _AUTHOR;
		private String _KEYWORDS;
		private String _COMMENTS;
		
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public String DB{	get{ return _DB;} set{_DB = value;} }
		public String TRANS_TYPE{	get{ return _TRANS_TYPE;} set{_TRANS_TYPE = value;} }
		public String REFERENCE{	get{ return _REFERENCE;} set{_REFERENCE = value;} }
		public String URL{	get{ return _URL;} set{_URL = value;} }
		public String TITLE{	get{ return _TITLE;} set{_TITLE = value;} }
		public String CATEGORY{	get{ return _CATEGORY;} set{_CATEGORY = value;} }
		public String SUBJECT{	get{ return _SUBJECT;} set{_SUBJECT = value;} }
		public String AUTHOR{	get{ return _AUTHOR;} set{_AUTHOR = value;} }
		public String KEYWORDS{	get{ return _KEYWORDS;} set{_KEYWORDS = value;} }
		public String COMMENTS{	get{ return _COMMENTS;} set{_COMMENTS = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public DocLinkInfo()
		{
			_ID = 0;
			_DB = "";
			_TRANS_TYPE = "";
			_REFERENCE = "";
			_URL = "";
			_TITLE = "";
			_CATEGORY = "";
			_SUBJECT = "";
			_AUTHOR = "";
			_KEYWORDS = "";
			_COMMENTS = "";
		}
		public DocLinkInfo(
		Int32 ID,
		String DB,
		String TRANS_TYPE,
		String REFERENCE,
		String URL,
		String TITLE,
		String CATEGORY,
		String SUBJECT,
		String AUTHOR,
		String KEYWORDS,
		String COMMENTS
		)
		{
			_ID = ID;
			_DB = DB;
			_TRANS_TYPE = TRANS_TYPE;
			_REFERENCE = REFERENCE;
			_URL = URL;
			_TITLE = TITLE;
			_CATEGORY = CATEGORY;
			_SUBJECT = SUBJECT;
			_AUTHOR = AUTHOR;
			_KEYWORDS = KEYWORDS;
			_COMMENTS = COMMENTS;
		}
		public DocLinkInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_DB = dr[Field.DB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DB.ToString()]);
				_TRANS_TYPE = dr[Field.TRANS_TYPE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TRANS_TYPE.ToString()]);
				_REFERENCE = dr[Field.REFERENCE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.REFERENCE.ToString()]);
				_URL = dr[Field.URL.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.URL.ToString()]);
				_TITLE = dr[Field.TITLE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TITLE.ToString()]);
				_CATEGORY = dr[Field.CATEGORY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CATEGORY.ToString()]);
				_SUBJECT = dr[Field.SUBJECT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SUBJECT.ToString()]);
				_AUTHOR = dr[Field.AUTHOR.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.AUTHOR.ToString()]);
				_KEYWORDS = dr[Field.KEYWORDS.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.KEYWORDS.ToString()]);
				_COMMENTS = dr[Field.COMMENTS.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.COMMENTS.ToString()]);
			}
		}
		public DocLinkInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_DB = dr[Field.DB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DB.ToString()]);
				_TRANS_TYPE = dr[Field.TRANS_TYPE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TRANS_TYPE.ToString()]);
				_REFERENCE = dr[Field.REFERENCE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.REFERENCE.ToString()]);
				_URL = dr[Field.URL.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.URL.ToString()]);
				_TITLE = dr[Field.TITLE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TITLE.ToString()]);
				_CATEGORY = dr[Field.CATEGORY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CATEGORY.ToString()]);
				_SUBJECT = dr[Field.SUBJECT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SUBJECT.ToString()]);
				_AUTHOR = dr[Field.AUTHOR.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.AUTHOR.ToString()]);
				_KEYWORDS = dr[Field.KEYWORDS.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.KEYWORDS.ToString()]);
				_COMMENTS = dr[Field.COMMENTS.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.COMMENTS.ToString()]);
			}
		}
		public DocLinkInfo(DocLinkInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_DB = objEntr.DB;			
			_TRANS_TYPE = objEntr.TRANS_TYPE;			
			_REFERENCE = objEntr.REFERENCE;			
			_URL = objEntr.URL;			
			_TITLE = objEntr.TITLE;			
			_CATEGORY = objEntr.CATEGORY;			
			_SUBJECT = objEntr.SUBJECT;			
			_AUTHOR = objEntr.AUTHOR;			
			_KEYWORDS = objEntr.KEYWORDS;			
			_COMMENTS = objEntr.COMMENTS;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("DocLink");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.DB.ToString(), typeof(String)),
				new DataColumn(Field.TRANS_TYPE.ToString(), typeof(String)),
				new DataColumn(Field.REFERENCE.ToString(), typeof(String)),
				new DataColumn(Field.URL.ToString(), typeof(String)),
				new DataColumn(Field.TITLE.ToString(), typeof(String)),
				new DataColumn(Field.CATEGORY.ToString(), typeof(String)),
				new DataColumn(Field.SUBJECT.ToString(), typeof(String)),
				new DataColumn(Field.AUTHOR.ToString(), typeof(String)),
				new DataColumn(Field.KEYWORDS.ToString(), typeof(String)),
				new DataColumn(Field.COMMENTS.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.DB.ToString()] = _DB;
			row[Field.TRANS_TYPE.ToString()] = _TRANS_TYPE;
			row[Field.REFERENCE.ToString()] = _REFERENCE;
			row[Field.URL.ToString()] = _URL;
			row[Field.TITLE.ToString()] = _TITLE;
			row[Field.CATEGORY.ToString()] = _CATEGORY;
			row[Field.SUBJECT.ToString()] = _SUBJECT;
			row[Field.AUTHOR.ToString()] = _AUTHOR;
			row[Field.KEYWORDS.ToString()] = _KEYWORDS;
			row[Field.COMMENTS.ToString()] = _COMMENTS;
			return row;
		}
        #endregion InitTable
    }
}
